package in.smartride.server;

import in.smartride.dataInterface.DataHandler;
import in.smartride.dataInterface.LandMark;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class temp
 */
public class GetLandMarks extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * Default constructor.
	 */
	public GetLandMarks() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		DataHandler dh = new DataHandler();
		List<LandMark> lm = dh.getAllLandmarks();
		
		//ObjectOutputStream oo = new ObjectOutputStream(response.getOutputStream());
		for(LandMark landMark:lm){
			response.getWriter().write(landMark.getLocationName() + "@" +  landMark.getLatitude()+ "@" + landMark.getLongitude()+ "@" + landMark.getId() + "~");
			//oo.writeBytes(landMark.getLocationName());
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
